package gold.digger;

import gold.vo.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC669 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public TreeNode trimBST(TreeNode root, int low, int high) {
            if (null == root) return null;
            if (root.val > high) return trimBST(root.left, low, high);
            if (root.val < low) return trimBST(root.right, low, high);
            root.left = trimBST(root.left, low, high);
            root.right = trimBST(root.right, low, high);
            return root;
        }
    }

    public void run() {
        Solution solution = new Solution();
//        TreeNode root = TreeNode.createTree("3,0,4,null,2,null,null,1");
        TreeNode root = TreeNode.createTree("1,null,2");
        System.out.println(solution.trimBST(root, 1, 3));
    }

    public static void main(String[] args) throws Exception {
        LC669 an = new LC669();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
